﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Cryptography;
using System.Text;

namespace ManagerVerification
{
    public partial class WebForm2 : System.Web.UI.Page
    {
       

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void OkBtn_Click(object sender, EventArgs e)
        {
            string pass = Passwd.ToString();
            string chpass = Passwdch.ToString();
            string logname = LogIn.Text;

            if (string.IsNullOrEmpty(pass) || pass != chpass)
            {
                //Response.Redirect(Request.RawUrl);
                //LogIn.Text = logname;
                ErrMsg.Visible = true;

            }
            else
            {
                DataSet1TableAdapters.ADD_ManagerAccountTableAdapter add_ManName = new DataSet1TableAdapters.ADD_ManagerAccountTableAdapter();
                //byte[] Password = pass.ToArray();
                
                SHA256 ShaM = new SHA256Managed();
                byte[] encPassword = ShaM.ComputeHash(Encoding.ASCII.GetBytes(pass));

                add_ManName.GetData(logname, encPassword);
                Response.Redirect("MainForm.aspx");
                
            }
        }
    }
}